<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="sf" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript" src="<%=basePath%>/res/js/jquery-1.8.3.js"></script>
	<script type="text/javascript">
		function	toPage(pageNo){
			$('#pageNo').val(pageNo);
			$('#frm').submit();
		}
		$(function(){
			$('#btnGo').click(function(){
				toPage($('#pageNo').val());
			});
			
			$('table thead tr').css('background-color', '#ADD8E6');
			$('table tbody tr:odd').css('background-color', '#90EE90');
		});
		
		function	doDelete(id){
			if(confirm('是否删除本记录？')){
				location = 'delete/' + id;
			}
		}
		function logout(){
			if(confirm("是否退出？")){
				location = 'logout';
			}
		}
	</script>
  </head>
  
  <body>
  	<h1>商务会员管理系统</h1>
  	用户名：${USERS.name } &nbsp;&nbsp;&nbsp;&nbsp;
  	用户类型：${USERS.userType.name }&nbsp;&nbsp;&nbsp;&nbsp;
  	<a href="javascript:logout()" >退出</a>
  	<hr>
  	<a href="modifyPwd">修改密码</a>&nbsp;&nbsp;&nbsp;&nbsp;
  	<c:if test="${USERS.userType.id == 1 }">
  		<a href="findPage">查看所有会员</a>  	
  	<hr>
	<sf:form action="findPage" id="frm" modelAttribute="page">
		用户名：<sf:input path="con"/>
		<sf:button onclick="toPage(1)">查询</sf:button>
		<table >
			<thead>
				<tr>
					<th>序号</th>
					<th>用户名</th>
					<th>用户类别</th>
					<th>用户状态</th>
					<th>最后修改时间</th>
				</tr>
			</thead>
			<tbody>
				<c:if test="${page.total == 0}">
					<tr>
						<td colspan='5' align='center' style="font-weight:bold">
							抱歉，暂无数据
						</td>
					</tr>
				</c:if>
				<c:forEach items="${page.list}" var="u" varStatus="s">
					<tr>
						<td>${s.index + 1} </td>
						<td>${u.name}</td>
						<td>${u.userType.name}</td>
						<td>
							<c:if test="${u.status == 0}">冻结</c:if>
							<c:if test="${u.status == 1}">正常</c:if>						
						</td>
						<td><fmt:formatDate value="${u.last_modify_time}" pattern="yyyy-MM-dd" /></td>
					</tr>
				</c:forEach>
			</tbody>
			<tfoot>
				<tr>
					<td colspan="5">
						<a href="javascript:toPage(1)">首页</a>
						<a href="javascript:toPage(${page.previous })">上一页</a>
							
						${page.pageNo } / ${page.totalPage }
						
						<a href="javascript:toPage(${page.next })">下一页</a>
						<a href="javascript:toPage(${page.totalPage })">末页</a>
						
						<sf:hidden path="pageNo" id="pageNo" />
					</td>
				</tr>
			</tfoot>
		</table>	
	</sf:form>
	</c:if>
  </body>
</html>
